(el-get 'sync '(yasnippet))

(require 'yasnippet)

(setq yas-snippet-dirs
      '("~/.emacs.d/el-get/yasnippet/snippets"                 ;; personal snippets
        "~/.emacs.d/personal/snippets"                 ;; foo-mode and bar-mode snippet collection
        "~/.emacs.d/personal/snippets"                 ;; the yasmate collection
        "~/.emacs.d/personal/snippets"                 ;; the default collection
        ))
(yas-global-mode 1)

;; Remove Yasnippet's default tab key binding
(define-key yas-minor-mode-map (kbd "<tab>") nil)
(define-key yas-minor-mode-map (kbd "TAB") nil)
;; Set Yasnippet's key binding to shift+tab
(define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)

;; The latest version of yasnippets doesn’t play well with Org-mode,
;; the following function allows these two to play nicely together.
(defun yas/org-very-safe-expand ()
  (let ((yas/fallback-behavior 'return-nil)) (yas/expand)))

(defun yas/org-setup ()
  ;; yasnippet (using the new org-cycle hooks)
  (make-variable-buffer-local 'yas/trigger-key)
  (setq yas/trigger-key [tab])
  (add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
  (define-key yas/keymap [tab] 'yas/next-field))



(provide 'init-yasnippet)
